<!-- include tpl=head -->
<div class="tips">
	{lang当前位置：}<a href="{url ctrl=wealth/}">{lang财富方案}</a>
	&raquo; <b class="red">{$rs.title}</b>{lang收支规则}
	<div class="clear"></div>
</div>
<script type="text/javascript">
function delete_it(id)
{
	$.dialog.confirm('{lang确定要删除当前规则吗？}',function(){
		var url = get_url('wealth','delete_rule','id='+id);
		var rs = $.phpok.json(url);
		if(rs.status == 'ok'){
			$.dialog.alert('{lang删除成功}',function(){
				$.phpok.reload();
			},'succeed');
		}else{
			$.dialog.alert(rs.content);
			return false;
		}
	});
}
function update_it(id)
{
	var url = get_url('wealth','save_rule','id='+id);
	$("#set_rule_"+id).ajaxSubmit({
		'url':get_url('wealth','save_rule','id='+id),
		'type':'post',
		'dataType':'json',
		'success':function(rs){
			if(rs.status){
				$.dialog.alert('{lang规则编辑成功}',function(){
					$.phpok.reload();
				},'succeed');
			}else{
				$.dialog.alert(rs.info);
				return false;
			}
		}
	});
	return false;
}
$(document).ready(function(){
	$("#add_rule").submit(function(){
		$(this).ajaxSubmit({
			'url':"{url ctrl=wealth func=save_rule wid=$rs.id/}",
			'type':'post',
			'dataType':'json',
			'success':function(rs){
				if(rs.status){
					$.dialog.alert('{lang规则创建成功}',function(){
						$.phpok.reload();
					},'succeed');
				}else{
					$.dialog.alert(rs.info);
					return false;
				}
			}
		});
		return false;
	});
});
</script>
<div class="help">
	<ol>
		<li>值：此框支持填写负数，正数，负数表示扣除，当{$rs.title}为0时，不能再执行扣除操作</li>
		<li>登录获取财富同一天仅限第一次有效</li>
		<li>仅在订单中支持变量price支持数学计算，如-(price/10+10)</li>
		<li>对象：所有财富在未指定规则时，都计算到用户，除非您指定了介绍人（也就是推荐人）</li>
		<li>目前用户级别请到：<span class="red">data/xml/user_agent.xml</span> 修改</li>
		<li>主题支持变量integral，支持数学计算，如-(integral/10+10)，此参数也支持在订单中使用（仅限订单中有关联的产品）</li>
	</ol>
</div>
<table width="100%" cellpadding="0" cellspacing="0" class="list">
<tr>
	<th width="75">ID</th>
	<th width="220">{lang执行动作}</th>
	<th width="220">{lang值}</th>
	<th width="220">{lang对象}</th>
	<th width="75">{lang排序}</th>
	<th class="lft">{lang操作}</th>
</tr>
<!-- loop from=$rslist key=$key value=$value -->
<form method="post" id="set_rule_{$value.id}" onsubmit="return update_it('{$value.id}')">
<tr>
	<td class="center">{$value.id}</td>
	<td class="center">
		<select name="action">
			<!-- loop from=$alist key=$k value=$v id=$tmpid -->
			<option value="{$k}"{if $value.action == $k} selected{/if}>{$v}</option>
			<!-- /loop -->
		</select>
	</td>
	<td class="center"><input type="text" name="val"  class="center" value="{$value.val}"/></td>
	<td class="center">
		<select name="goal" id="goal_{$value.id}">
			<!-- loop from=$agentlist key=$k value=$v id=$tmpid -->
			<option value="{$k}"{if $value.goal == $k} selected{/if}>{$v}</option>
			<!-- /loop -->
		</select>
	</td>
	<td class="center"><input type="text" name="taxis" id="taxis_{$value.id}" value="{$value.taxis}" class="short center" /></td>
	<td>
		<div class="button-group">
			<input type="submit" value="{lang编辑}" class="layui-btn" />
			<input type="button" value="{lang删除}" onclick="delete_it('{$value.id}')" class="layui-btn" />
		</div>
	</td>
</tr>
</form>
<!-- /loop -->
<form method="post" id="add_rule">
<tr>
	<td class="center">添加</td>
	<td class="center">
		<select name="action">
			<option value="">{lang动作…}</option>
			<!-- loop from=$alist key=$key value=$value id=$tmpid -->
			<option value="{$key}">{$value}</option>
			<!-- /loop -->
		</select>
	</td>
	<td class="center"><input type="text" name="val"  class="center"/></td>
	<td class="center">
		<select name="goal">
			<!-- loop from=$agentlist key=$key value=$value id=$tmpid -->
			<option value="{$key}">{$value}</option>
			<!-- /loop -->
		</select>
	</td>
	<td class="center"><input type="text" name="taxis" value="255" class="short center" /></td>
	<td><input type="submit" value="{lang添加}" class="layui-btn" /></td>
</tr>
</form>
</table>
<!-- include tpl=foot -->